package com.hmall.pay.mq;


import com.hmall.pay.constants.MqConstants;
import com.hmall.pay.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotelListener {

    @Autowired
    private SearchService searchService;

    /**
     * 监听增或修改的业务
     *
     * @param id 酒店id
     */
    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Long id) {
        searchService.insertById(id);
    }

    /**
     * 监听删除的业务
     *
     * @param id
     */
    @RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)
    public void listenHotelDelete(Long id) {
        searchService.deleteById(id);
    }



}